package com.core.common;


import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 返回结果
 *
 * @param <T>
 */
@Data
public class ImportResultVO<T> implements Serializable {
    private List<T> dataList;
    private String msg;
    private boolean success;
    private Integer code;


    public static <T> ImportResultVO fail(List<T> dataList) {
        ImportResultVO vo = new ImportResultVO();
        vo.setSuccess(false);
        vo.setCode(500);
        vo.setDataList(dataList);
        vo.setMsg("导入失败，详细参见异常信息列表");
        return vo;
    }

    public static <T> ImportResultVO fail(List<T> dataList, String msg) {
        ImportResultVO vo = new ImportResultVO();
        vo.setSuccess(false);
        vo.setCode(500);
        vo.setDataList(dataList);
        vo.setMsg(msg);
        return vo;
    }

    public static <T> ImportResultVO fail(List<T> dataList, Integer code, String msg) {
        ImportResultVO vo = new ImportResultVO();
        vo.setSuccess(false);
        vo.setCode(code);
        vo.setDataList(dataList);
        vo.setMsg(msg);
        return vo;
    }

    public static <T> ImportResultVO success(List<T> dataList) {
        ImportResultVO vo = new ImportResultVO();
        vo.setSuccess(true);
        vo.setCode(200);
        vo.setDataList(dataList);
        vo.setMsg("导入成功");
        return vo;
    }
}
